<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>商户登录</title>
    <link rel="stylesheet" type="text/css" href="{{asset('css/home/reset.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{asset('css/home/style.css')}}"/>
    <link rel="stylesheet" href="{{asset('css/home/qy_style.css')}}">
    <link rel="shortcut icon" type="image/x-icon" href='{{asset('image/heeypay/anyun.ico')}}' media="screen" />
    <link rel="stylesheet" type="text/css" href="{{asset('css/heeypay/common.css')}}"  />

    <script src="{{asset('js/jquery.min.js')}}"></script>
    <script src="{{asset('js/buz/common.js')}}"></script>
</head>
<body>
@include('layouts.home.header', ['active' => 'login'])
<!--content-->
<div class="content content1">
    <div class="loginbox" style="height: 550px">
        <i><img src="{{asset('image/home/loginscene.png')}}"/></i>
        <img src="{{asset('image/home/loginlogo.png')}}" class="loginlogo"/>
        <form action="" method="post">
            <div class="myInput">
                <input type="text" id="login_user" placeholder="用户名" name="username"/>
            </div>
            <div class="myInput">
                <input type="password" id="login_pwd" placeholder="密码" name="userpassword"/>
            </div>
            <div class="myInput">
                <input style="width: 60%" type="text" id="validcode" placeholder="验证码" name="captcha"/>
                <img style="position: absolute;margin-left: 38px;margin-top: 5px;" src="{{captcha_src()}}" onclick="this.src='{{captcha_src()}}?r='+Math.random()">
            </div>
            <a href="javascript:void(0);" class="btn loginbtn">登录</a>
            <a href="{{route('buz.register_one')}}" class="btn regisbtn">注册</a>
            <p class="clearfix forgetBox">
                <a href="/forgetpwd" class="fl">忘记密码</a>
                {{--<span class="fr">使用有问题？--}}
                    {{--@foreach(config('app.website.CONTACT_QQ') as $qq)--}}
                        {{--<a href="#" class="contactQQ" data-qq="{{$qq}}"><i class="icon icon-serv"></i>QQ客服</a>--}}
                    {{--@endforeach()--}}
                    {{--<a href="javascript:void(0);" id="contactQQ" data-qq="{{config('app.website.CONTACT_QQ')}}">意见反馈</a></span>--}}
            </p>
        </form>
    </div>
</div>
</body>
<script>
    $(".contactQQ").click(function () {
        var qq = $(this).attr('data-qq');
        var kefu101 = "http://wpa.qq.com/msgrd?v=3&uin="+qq+"&site=oicqzone.com&menu=yes";
        var kefu102 = "mqqwpa://im/chat?chat_type=wpa&uin="+qq+"&version=1&src_type=web&web_src=oicqzone.com";
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) || /(Android)/i.test(navigator.userAgent)) {
            window.open(kefu102);
        }else {
            window.open(kefu101);
        }
    });

    $(".loginbtn").click(function () {

        var username = $("#login_user").val(),
            password = $("#login_pwd").val(),
            capthca = $("#validcode").val(); //验证码

        var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
        if(username.length == 0){
            $("#login_user").focus()
            alert('请输入邮箱账号');
            return;
        }
        if(password.length == 0){
            $("#login_pwd").focus()
            alert('请输入密码')
            return;
        }
        if(!reg.test(username)){
            $("#login_user").focus()
            alert("登录账号必须是邮箱");
            return;
        }
        if (capthca.length == 0) {
            $("#validcode").focus();
            alert('请输入验证码');
            return;
        }
        $.ajax({
            url: "/api/auth/login",
            data: { username: username, password: password, captcha: capthca },
            type: 'post',
            success:function(e){
                if(e.code == 0){
                    var token = e.data.token;
                    localStorage.setItem('token',token);
                    localStorage.setItem('username',username);
                    window.location.href = '/index';
                }else if(e.code == 40003){
                    var str="";
                    var obj = e.message;
                    $.each(obj,function(i){
                        var childObj = obj[i];
                        for(var j=0;j<childObj.length;j++){
                            str += childObj[j]+"\n";
                        }
                    });
                    document.getElementById('validcode').src = '{{captcha_src()}}?t=' + Math.random();
                    alert(str);

//                    $("#errmsg").html(str);
//                    $("#loginbtn").text("登录").attr("disabled",false);
                }else {
                    document.getElementById('validcode').src = '{{captcha_src()}}?t=' + Math.random();
                    alert(e.message);
//                    $("#errmsg").html(e.message);
//                    $("#loginbtn").text("登录").attr("disabled",false);
                }

            }


        });
    })

</script>


</html>




